import Vue from 'vue'
import VueRouter from 'vue-router'
import routes from './router'

Vue.use(VueRouter)

const router = new VueRouter({

  routes
})
const HAS_LOGINED = 1
router.beforeEach((to,from,next)=>{
  if(to.name !== 'login'){
    if(HAS_LOGINED) next()
    else next({name:'login'})
  }else {
    if(HAS_LOGINED) next({name:'home'})
    else next()
  }
})

//router.beforeResolve()

router.afterEach((to,from)=>{
  //logining = false
})


export default router